<!--{template Header.htm}-->
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="javascript:history.back();"></a>

    <h1 class="mui-title">{$title}</h1>
</header>
<div class="mui-content">
    <form class="mui-input-group">
        <h5>新的密码：</h5>

        <div class="mui-input-row">
            <input type="password" name="userPass1" value="" id="userPass1" class="mui-input-clear mui-input"
                   placeholder="这里输入新密码" onClick="this.select()"/>
        </div>
        <h5>确认密码：</h5>

        <div class="mui-input-row">
            <input type="password" name="userPass2" value="" id="userPass2" class="mui-input-clear mui-input"
                   placeholder="再次输入新密码"/>
        </div>
    </form>
    <div class="mui-content-padded">
        <button class="mui-btn mui-btn-block mui-btn-primary" onclick="modifyPassword()">修改</button>
    </div>
    <div class="loader hide"></div>
</div>
<script type="text/javascript">
    function modifyPassword() {
        var userPass1 = jQuery.trim(jQuery("#userPass1").val());
        var userPass2 = jQuery.trim(jQuery("#userPass2").val());
        if (userPass1 == "") {
            alert("用户密码不能为空！");
            return false;
        } else if (userPass1 != userPass2) {
            alert("两次输入的密码不一致！");
            return false;
        }
        jQuery(".loader").show();
        userPass1 = encodeURIComponent(userPass1);
        jQuery.post("{$base_url}/api.php?c=User&a=modifyPassword", {
            token: '{$token}',
            password: userPass1,
        }, function (result) {
            jQuery(".loader").hide();
            alert(result.msg);
            if (result.code == 1) {
                window.location.reload();
            }
        }, "json");
        return false;
    }
</script>
<!--{template Footer.htm}-->